package com.bawei.mall.user.service.impl;

import com.bawei.common.security.utils.SecurityUtils;
import com.bawei.mall.user.domain.CusUserFootprintInfo;
import com.bawei.mall.user.mapper.CusUserFootprintMapper;
import com.bawei.mall.user.service.ICusUserFootprintService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName CusUserFootprintServiceImpl
 * @Description 描述
 * @Author ZiZheng.Li
 * @Date 2024/7/2 16:52
 */
@Service
@Slf4j
public class CusUserFootprintServiceImpl implements ICusUserFootprintService {
    @Autowired
    private CusUserFootprintMapper cusUserFootprintMapper;
    @Override
    public List<CusUserFootprintInfo> selectCusUserFootprintInfoList() {
        Long memberId=SecurityUtils.getUserId();

        log.info("用户ID："+memberId+" 用户名称："+SecurityUtils.getUsername()+" User："+SecurityUtils.getLoginCusUser());
        //获取当前登录人信息 和 前台传过来的数据
        if (memberId == null || memberId == 0){
            throw new RuntimeException("您还未登录,请尽快登录");
        }

        return cusUserFootprintMapper.selectCusUserFootprintInfoList(memberId);
    }

    @Override
    public void clearFootprintInfos() {
        cusUserFootprintMapper.clearFootprintInfos();
    }

    @Override
    public void addUserFootprintInfo(CusUserFootprintInfo cusUserFootprintInfo) {
        //获取当前登录人信息 和 前台传过来的数据
        if (SecurityUtils.getUserId() == null || SecurityUtils.getUserId() == 0){
            throw new RuntimeException("您还未登录,请尽快登录");
        }
        cusUserFootprintInfo.setMemberId(SecurityUtils.getUserId());
        cusUserFootprintInfo.setCreateBy(SecurityUtils.getUsername());
//        cusUserFootprintInfo.setProductId();
//        cusUserFootprintInfo.setProductName();
//        cusUserFootprintInfo.setProductPic();
//        cusUserFootprintInfo.setProductPrice();
//        cusUserFootprintInfo.setProductSubtitle();
    }
}
